<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:ui="http://java.sun.com/jsf/facelets" 
	  xmlns:p="http://primefaces.prime.com.tr/ui" >
	  
	<f:view contentType="text/html"/>
	<f:metadata>
		<f:viewParam name="id" value="#{usuarioBean.usuario}" />
	</f:metadata>
	<h:body>
		<ui:composition template="layout.xhtml">
		<ui:define name="conteudo">
		<h:messages style="color: red"/>
		<h2>Cadastro de Usuários</h2>
		<h:form id="dados">
			<fieldset>
				<legend>Dados do Usuário</legend>
			
			<h:panelGrid columns="2">
				<h:outputLabel value="Id:" for="id" 
						     rendered="#{usuarioBean.usuario.idUsuario != null}"
						     />
				<h:inputText id="id" 
							 value="#{usuarioBean.usuario.idUsuario}"
							 rendered="#{usuarioBean.usuario.idUsuario != null}"
							 readonly="true"/>

				<h:outputLabel value="Associado (*):"/>
				<h:selectOneMenu value="#{usuarioBean.idAssociado}">
					<f:selectItems value="#{associadoBean.associados}" 
					  var="a" itemValue="#{a.id}" itemLabel="#{a.nome}"/>
				</h:selectOneMenu> 
				
				<h:outputLabel value="Login (*):" for="login"/>
				<h:inputText id="login" value="#{usuarioBean.usuario.login}" required="true" requiredMessage="Informe o Login do Usuário"/>
				
				<h:outputLabel value="Senha (*):" for="senha"/>
				<h:inputSecret id="senha" value="#{usuarioBean.usuario.senha}" maxlength="8" required="true" requiredMessage="Informe a Senha do Usuário"/>
			</h:panelGrid>
			<br></br>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
				
				<h:commandLink actionListener ="#{usuarioBean.salvar}"  title="Salvar">
					<img src="resources/imagens/ok.jpg" alt="Salvar"/> </h:commandLink>
				
					&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
				
				<a href="#{facesContext.externalContext.request.contextPath}/usuarioList.xhtml" title="Cancelar">
					<img src="resources/imagens/Xcancelar.jpg" alt="Cancelar"/> </a>
			</fieldset>
		</h:form>
	</ui:define>
	</ui:composition>
	</h:body>
</html>